package com.mayuhao.homefont.controller;

import cn.hutool.json.JSONUtil;
import com.mayuhao.homefont.entity.CssHomeFont;
import com.mayuhao.homefont.service.ICssHomeFontService;
import com.mayuhao.homefont.util.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 马宇豪
 * @since 2022-11-15
 */
@RestController
//@RequestMapping("/css-home-font")
public class CssHomeFontController {
    @Resource
    private ICssHomeFontService homeFontService;

    @PutMapping("/savetitle")
    public Result saveTitle(@RequestBody CssHomeFont cssHomeFont) {
        return new Result(true, "oksave", homeFontService.updateById(cssHomeFont));
    }

    @GetMapping("/getall")
    public Result getTitle() {
        return new Result(true, "okget", JSONUtil.parse(homeFontService.list()));
    }

    @PutMapping("/savecontext")
    public Result saveContext(@RequestBody CssHomeFont cssHomeFont) {
        return new Result(true, "oksave", homeFontService.updateById(cssHomeFont));
    }
}
